package com.lhy.wanandroid.ui.login

import android.util.Log
import androidx.lifecycle.Observer
import com.lhy.demo.R
import com.lhy.demo.common.MyApplication
import com.lhy.wanandroid.base.MyBaseVmActivity
import com.lhy.wanandroid.ui.main.MianKotlinActivity
import com.xiaojianjun.wanandroid.ext.showToast
import kotlinx.android.synthetic.main.activity_login_kotlin.*

class LoginKotlinActivity:MyBaseVmActivity<LoginViewModel>() {
//    val userInfo=MutableLiveData<UserInfo>()
    override fun viewModeClass(): Class<LoginViewModel> {
        return LoginViewModel::class.java
    }

    override fun initData() {
        btn_login_commit.setOnClickListener {
//            when{
//                et_login_phone.text.toString().isEmpty() -> et_login_phone.error=getString(R.string.account_can_not_be_empty)
//                et_login_password.text.toString().isEmpty() -> et_login_password.error=getString(R.string.password_can_not_be_empty)
//                else -> mViewModel.login(et_login_phone.text.toString(),et_login_password.text.toString())
//            }
            startActivity(MianKotlinActivity::class.java)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_login_kotlin
    }

    override fun initView() {
    }

    override fun observe() {
        mViewModel.loginBean.observe(this@LoginKotlinActivity, Observer {
            Log.i("tag", "observe: ${it.toString()}")
            MyApplication.getInstance().showToast(it.toString())
            if (it != null) {
                startActivity(MianKotlinActivity::class.java)
            }
        })
        super.observe()
    }
}